package routers

import (
	v1 "zhejianglab/gin-apiserver/routers/api/v1"

	"github.com/gin-gonic/gin"
)

// InitAlarmRouter init the alarm routers
func InitAlarmRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/alarm")
	{
		apiV1.POST("/new", v1.AddNewAlarm)
		apiV1.GET("", v1.GetAlarmWithType)
		apiV1.PUT("/:id", v1.UpdateAlarm)
		apiV1.DELETE("/:id", v1.DeleteAlarm)
	}

}

// InitAlgoRouter init the algorithm routers
func InitAlgoRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/algorithm")
	{
		apiV1.POST("/new", v1.AddNewAlgo)
		apiV1.GET("/:id", v1.GetAlgo)
		apiV1.GET("", v1.GetAlgoWithType)
		apiV1.PUT("/:id", v1.UpdateAlgo)
		apiV1.DELETE("/:id", v1.DeleteAlgo)
	}

}

// InitDatasetRouter init the Dataset routers
func InitDatasetRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/dataset")
	{
		apiV1.POST("/new", v1.AddNewDataset)
		apiV1.GET("", v1.GetDataset)
		apiV1.GET("/images/:id", v1.GetDatasetImages)
		apiV1.PUT("/:id", v1.UpdateDataset)
		apiV1.DELETE("/:id", v1.DeleteDataset)
	}

}

// InitClueRouter init the Clue routers
func InitClueRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/clue")
	{
		apiV1.POST("/new", v1.AddNewClue)
		apiV1.GET("", v1.GetClue)
		apiV1.PUT("/:id", v1.UpdateClue)
		apiV1.DELETE("/:id", v1.DeleteClue)
	}
}

// InitConfigRouter init the config routers
func InitConfigRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/config")
	{
		apiV1.POST("/new", v1.AddNewConfig)
		apiV1.GET("", v1.GetConfigWithAlgorithmName)
		apiV1.PUT("/:id", v1.UpdateConfig)
		apiV1.DELETE("/:id", v1.DeleteConfig)
	}

}

// InitDownloadRouter init the Download routers
func InitDownloadRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/download")
	{
		apiV1.POST("/new", v1.AddNewDownload)
		apiV1.GET("/:id", v1.GetDownload)
		apiV1.PUT("/:id", v1.UpdateDownload)
		apiV1.DELETE("/:id", v1.DeleteDownload)
	}

}

// InitFileRouter init the file routers
func InitFileRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/file")
	{
		apiV1.POST("", v1.UploadFile)
		apiV1.GET("", v1.GetAllFileInfo)
		apiV1.DELETE("/:fileName", v1.DeleteFile)
		apiV1.GET("/:fileName", v1.DownloadFile)
	}

}

// InitUserRouter init the user routers
func InitUserRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/user")
	//apiV1.Use(myjwt.JWT())
	{
		apiV1.POST("/login", v1.UserLogin)
		apiV1.POST("", v1.CreateUser)
		apiV1.GET("/:id", v1.GetUser)
		apiV1.PUT("/:id", v1.UpdateUser)
		apiV1.DELETE("/:id", v1.DeleteUser)
	}

}

// InitVideoRouter init the Video routers
func InitJobRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/job")
	{
		apiV1.POST("/new", v1.AddNewJob)
		apiV1.POST("/restart/:id", v1.ReStartJob)
		apiV1.GET("/user/:id", v1.GetJobByUserID)
		apiV1.GET("", v1.GetJob)
		apiV1.GET("/result/:id", v1.GetResult)
		apiV1.PUT("/:id", v1.UpdateJob)
		apiV1.DELETE("/:id", v1.DeleteJob)
	}

}

// InitVideoRouter init the Video routers
func InitVideoRouter(router *gin.RouterGroup) {
	apiV1 := router.Group("/api/v1/video")
	{
		apiV1.POST("/new", v1.AddNewVideo)
		apiV1.GET("/:id", v1.GetVideo)
		apiV1.GET("", v1.GetVideoWithUserID)
		apiV1.PUT("/:id", v1.UpdateVideo)
		apiV1.DELETE("/:id", v1.DeleteVideo)
	}

}
